//-----------------------------------------------------------------------------
// SWDA：关于绘制角色立绘的补充定义
//-----------------------------------------------------------------------------
ImageManager.SWDA_loadSystemFace = function (filename, hue) {
    return this.loadBitmap('img/system/actors/', filename, hue, true);
};

ImageManager.SWDA_loadSystemPortrait = function (filename, hue) {
    return this.loadBitmap('img/system/actors/', filename, hue, false);
};

ImageManager.reservePortrait = function (actor, hue, reservationId) {
    const portraitName = "Portrait" + actor.actorId() + ((actor.actorId()==1 && $gameSwitches.value(299)) ? "a" : "");
    return this.reserveBitmap('img/system/actors/', portraitName, hue, false, reservationId);
};
ImageManager.reserveBattleFace = function (actor, hue, reservationId) {
    const battleFaceName = "BattleFace" + actor.actorId() + ((actor.actorId()==1 && $gameSwitches.value(299)) ? "a" : "");
    return this.reserveBitmap('img/system/actors/', battleFaceName, hue, false, reservationId);
};

ImageManager.loadCharacter = function(filename, hue) {
    return this.loadBitmap('img/characters/', filename, hue, true);
};


/***********************************************************************************
 * 读取图片，当读取不到时不报错，而显示一张默认图片
 * @note 当传入空的defaultUrl时，则显示空图片
 ***********************************************************************************/
 ImageManager.loadDefaultBitmap = function ([folder, filename], [defaultFolder, defaultFilename], hue, smooth) {
    if (!filename) return this.loadEmptyBitmap()

    let path = folder + encodeURIComponent(filename) + '.png';

    let defaultPath = ''
    if (defaultFilename) {
        defaultPath = defaultFolder + encodeURIComponent(defaultFilename) + '.png';
    }
    let bitmap = this.loadNormalBitmap(path, hue || 0);
    bitmap.setDefault(defaultPath, true)
    bitmap.smooth = smooth;
    return bitmap;
};


/***********************************************************************************
 * 读取预览图
 ***********************************************************************************/
 ImageManager.SWDA_loadPreview = ImageManager.SWDA_loadPreview || function (folder = 'items', filename, hue) {
    const url = [`img/preview/${folder}/`, filename]
    const defaultUrl = []
    return this.loadDefaultBitmap(url, defaultUrl, hue, true);
};


